﻿@page "/categories/list"
@inherits PageBase

<PageContainer>
    <Breadcrumb>
        <Breadcrumb>
            <BreadcrumbItem><Icon Type="home"></Icon></BreadcrumbItem>
            <BreadcrumbItem><Icon Type="switcher"></Icon><span>分类管理</span></BreadcrumbItem>
            <BreadcrumbItem><Icon Type="bars"></Icon><span>分类列表</span></BreadcrumbItem>
        </Breadcrumb>
    </Breadcrumb>
    <ChildContent>
        <Card>
            <Table TItem="GetAdminCategoryDto" DataSource="@categories" Bordered=@true Size=@TableSize.Small>
                <Column @bind-Field="@context.Id" Title="Id" Sortable="false"></Column>
                <Column @bind-Field="@context.Total" Title="文章总数" Sortable="false"></Column>
                <Column @bind-Field="@context.Name" Title="分类名称" Sortable="false"></Column>
                <Column @bind-Field="@context.Alias" Title="分类别名" Sortable="false"></Column>
                <ActionColumn Title="操作">
                    <Space Size="@("small")">
                        <SpaceItem>
                            <Button Type="@ButtonType.Primary" OnClick="_ => Open(context)">编辑</Button>
                        </SpaceItem>
                        <SpaceItem>
                            <Popconfirm Title="确定删除吗?"
                                        Icon="close-circle"
                                        OnConfirm="(async () => await DeleteAsync(context.Id))">
                                <Button Danger>删除</Button>
                            </Popconfirm>
                        </SpaceItem>
                    </Space>
                </ActionColumn>
            </Table>
        </Card>
        <Drawer Closable="true"
                Visible="@visible"
                Placement="right"
                Title='("编辑分类")'
                Width="500"
                OnClose="_ => Close()">
            <Form Model="@input"
                  LabelColSpan="7"
                  WrapperColSpan="10"
                  OnFinish="HandleSubmit">
                <FormItem Label="分类名称">
                    <Input @bind-Value="@context.Name" />
                </FormItem>
                <FormItem Label="分类别名">
                    <Input @bind-Value="@context.Alias" />
                </FormItem>
                <FormItem WrapperColOffset="7" WrapperColSpan="10">
                    <Button Type="@ButtonType.Primary" HtmlType="submit">保存</Button>
                </FormItem>
            </Form>
        </Drawer>
    </ChildContent>
</PageContainer>